<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>类中方法this指向</title>
</head>
<body>
<script type="text/javascript">
    class Person {
        constructor(name, age) {
            this.name = name;
            this.age = age;
        }
        speak() {
            console.log(this)
        }
    }

    const p1 = new Person("tom", 19);
    p1.speak();     // 通过实例调用speak方法

    const x = p1.speak;
    x();        // undefined


</script>
</body>
</html>